<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>产品分享</title>
<link rel="stylesheet" type="text/css" href="../css/aui.css">
<link rel="stylesheet" type="text/css" href="../css/aui-slide.css">
<link rel="stylesheet" type="text/css" href="../css/aui-flex.css">
<link rel="stylesheet" type="text/css" href="../css/my.css">
<link rel="stylesheet" type="text/css" href="../css/index.css">
<link rel="stylesheet" type="text/css" href="../css/common.css">
</head>
<style>
html{ margin:0;padding:0;width:100%;height:100%;}
.aui-radio, .aui-checkbox{background: #000;opacity: .5;}
.dui .aui-radio:checked{opacity: 1;}
</style>
<body class="jb">
  <div class="aui-content-padded " style="margin-bottom: 0;">
    <div class="tb_zt_right aui-card-list aui-bu aui-padded-t-5">
      <div class="aui-padded-10 aui-padded-b-0 ">
        <div class="tb_zt_texttop ">
          <div class="tb_zt_text">
            <div class="tb_zt_texticon"><img src="../image/taobao.png" id="tjp-icon"></div>
            <div class="tb_zt_texttit" id="title"></div>
          </div>
        </div>
        <div class="tb_zt_textbottom ">
          <div class="tb_numbar">
            <div class="tb_price aui-padded-t-5"><b class="aui-font-size-20">¥<label id="price_after_quan">0</label></b><span>¥<span id="price">0</span></span></div>
            <div class="tb_num aui-list-item-right aui-padded-t-5"><span id="sales">0</span>人已买</div>
          </div>
          <div class="tb_numbar">
            <div class="tb_zt_bq aui-list-item-left" style=" margin-top:-10px"><!--  <span>预估赚¥8.88</span>  --></div>
            <div class="tb_yhq"><span id="quan_price">0</span>元优惠券</div>
          </div>
        </div>
        
      </div>
      <div class="aui-card-list aui-margin-t-15" style=" margin-bottom:0 !important;">
         <div class="aui-card-list-header aui-padded-b-0">
            <h3 class="xiangq">分享文案</h3> 
            <div class="tb_yhq" onclick="copyd()" tapmode>点我复制文案</div>
         </div>
         <div class="aui-card-list-content-padded aui-bg-default aui-margin-10" style="border-radius:10px;height: 7rem;overflow-y: auto;" id="text">
              
          </div>
      </div>
      <div class="aui-card-list-content-padded">
          <div class="aui-row aui-row-padded" id="pics" style="overflow-y: auto;height: 8rem;">
              <!-- <div class="aui-col-xs-3 dui">
                 <img src="../image/pro01.jpg">
                 <input class="aui-radio" type="checkbox" name="demo" checked="">
              </div>
              <div class="aui-col-xs-3 dui">
                 <img src="../image/pro01.jpg">
                 <input class="aui-radio" type="checkbox" name="demo">
              </div>
              <div class="aui-col-xs-3 dui">
                 <img src="../image/pro01.jpg">
                 <input class="aui-radio" type="checkbox" name="demo" checked="">
              </div>
              <div class="aui-col-xs-3 dui">
                 <img src="../image/pro01.jpg">
                 <input class="aui-radio" type="checkbox" name="demo" checked="">
              </div>
              <div class="aui-col-xs-3 dui">
                 <img src="../image/pro01.jpg">
                 <input class="aui-radio" type="checkbox" name="demo" checked="">
              </div> -->
          </div>
      </div>
    </div>
  </div>
<!-- 顶部end --> 
 <!-- 底部 -->
 <footer class="aui-bar aui-bar-tab jb">
    <div class="more_bar aui-padded-15 aui-padded-t-5">
        <div class="more_tit aui-text-center text-white aui-font-size-14">图片分享到</div>
        <div class="aui-row more_con aui-padded-t-15" tapmode onclick="share_open()">
             <div class="aui-col-xs-3 aui-text-center fang"><img src="../image/share/wx.png" ><p class="text-white aui-padded-t-5">微信</p></div>
             <div class="aui-col-xs-3 aui-text-center fang"><img src="../image/share/wx-circle.png"><p class="text-white aui-padded-t-5">朋友圈</p></div>
             <div class="aui-col-xs-3 aui-text-center fang"><img src="../image/share/qq.png"><p class="text-white aui-padded-t-5">QQ</p></div>
             <div class="aui-col-xs-3 aui-text-center fang"><img src="../image/share/sina-weibo.png"><p class="text-white aui-padded-t-5">微博</p></div>
        </div>
    </div>
  </footer>
    <!-- 底部end -->
<!-- 固定底部end -->
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/aui-slide.js"></script>
<script type="text/javascript" src="../script/zepto.min.js" ></script>
<script type="text/javascript" src="../script/common.js" ></script>
<script type="text/javascript">
    var item;
    apiready = function(){
        api.parseTapmode();
        item = api.pageParam;
        item.title = item.gtitle;
        $('#title').html(item.title||'');
        var imgs = {"0":"../image/taobao.png","1":"../image/tmall.png","2":"../image/jd.png","3":"../image/pinduoduo.png"}
        $('#tjp-icon').attr('src',imgs[item.is_tmall||'0']);
        $('#price').html(item.price||'0');
        $('#price_after_quan').html(item.price_after_quan||'0');
        $('#sales').html(item.sales||'0');
        $('#quan_price').html(item.quan_price);
        
        getData(item);
        
    }
    function getData(data){
      _loading2();
      _Ajax(window.APIServer.Share,'post',{values:data},'json',function(ret){
        _loading2_close();
        //.渲染页面
        if (ret.code==1) {
            $('#text').html(ret.data.text);
            var banner = '';
            $(ret.data.pics).each(function(k,v){
            banner += '<div class="aui-col-xs-3 dui"><label><img class="bimg" src="../image/faleimg.gif" _src="'+v+'" /><input class="aui-radio" type="checkbox" name="demo"></label></div>';
            });
            $('#pics').html(banner);
            $('#title').html(ret.data.title);
            $('#price').html(ret.data.price)
            $('#price_after_quan').html(ret.data.price_after_quan);
            $('#sales').html(ret.data.sales);
            $('#quan_price').html(ret.data.quan_price);

            imagedown('.bimg');
            //生成海报
            var types = ['淘宝','天猫','京东','拼多多'];
            var makeSharePic = api.require('makeSharePic');
            makeSharePic.makePicture({
                imgUrl:ret.data.pic,
                qrCode:ret.data.share_url,
                expressType:types[ret.data.is_tmall],
                goodTitle:'           '+ret.data.title,
                nowPriceStatus:'现价 ：￥'+ret.data.price,
                discountType:'券',
                discountPrice:ret.data.quan_price+'元',
                finalPriceType:'券后价 ',
                finalPrice:ret.data.price_after_quan,
                savePath:'cache://share_image',
                fileName:'share_'+ret.data.item_id+'.png',
                //insertImage:true,
                //isHtmlText:true,              
            },function(ret,err){
                _loading_close();
                if(ret.status){
                  $('#pics').prepend('<div class="aui-col-xs-3 dui"><label><img src="'+ret.filePath+'" /><input class="aui-radio" type="checkbox" name="demo" checked></label></div>');
                  //alert(JSON.stringify(ret));
                }else{
                  _toast('分享海报生成失败');
                  //alert(err.message);
                }
            });
        }else{
          _loading_close();
          _toast(ret.msg);
          
        }
            
        })
    }
    //复制文案
    function copyd(){
      copy($('#text').text());
    }
    
    //分享图片到
    function share_open(){
      var len = $('input[name=demo]:checked').length;
      if (len==0) {
        _toast('请选择要分享的图片');
        return false;
      }
      //请求
      _Ajax(window.APIServer.Task,'post',{values:{type:1}},'json',function(ret){});
      var imgs = new Array();
      $('input[name=demo]:checked').each(function(){
          imgs.push($(this).prev().attr('src'))
      });

      var sharedModule = api.require('shareAction');
      //alert(JSON.stringify(imgs))
      sharedModule.share({
          //text: invite_obj.title,
          type: 'image',
          images: imgs
      });
    }

</script>
</html>
